package demo.homework;

import java.io.*;

import static demo.until.FileUtil.FILE_PATH;

public class Demo2 {

    /**
     * 使用IO流实现文件拷贝
     * @param args
     * @throws IOException
     */


    public static void main(String[] args) throws IOException {
        String fromPath = "E:\\fileDemo.mp4";

        String toPath = FILE_PATH + "test.mp4";

        FileInputStream fis = new FileInputStream(fromPath);

        FileOutputStream fos = new FileOutputStream(toPath);

        byte[] buffer = new byte[fis.available()];

        int len;

        //fis.read(buffer)  将buffer.length个长度的字节数据写入到buffer数组中

        while((len = fis.read(buffer))!=-1){
            fos.write(buffer,0,len);
        }

        fis.close();
        fos.close();
    }
}
